#!/bin/bash

#
# extractemails -- by Dario Berzano <dario.berzano@gmail.com>
#
# Part of the lfscripts suite -- http://lfscripts.googecode.com/
#
# Reads a raw text file containing emails from stdin, and outputs on stdout one
# email per line. Duplicates are removed.
#

cat | \
  perl -pi -ne 's/[, \t<>]/\n/g' | \
  perl -ne '/([^\s]+@[^\s]+)/; print "$1\n"' | \
  sed -e '/^$/d' | \
  sort | uniq
